library(readxl)
library(randomForest)
# 导入数据
foodb <- read_csv("class_demo.csv")
foodb <- data.frame(foodb)#数据框处理
#classification_demo <- read_excel("classification_demo.xlsx")
load("RF-class.RData")#调用模型
desc_1<-read.table("class_des_sel.txt",sep = ",")[,1]#调用描述符
aa<-foodb[,desc_1]
data_pred<- data.frame(SMILES = foodb$moldb_smiles, aa)
unknowsweet.prediction <- predict(Randommodel, data_pred[,-1],type="prob")
unknowsweet.prediction <- data.frame(unknowsweet.prediction)
bb<-data.frame(foodb,unknowsweet.prediction)
result <- subset(bb, sweet >= 0.5)
#第二部分，甜度预测。
rf_model <- model

library(readxl)
result <- read_csv("regression_demo.csv")
result_1 <- data.frame(result)
load("RF_regress.RData")#调用模型
desc_value<-read.table("regress_des_sel.txt",sep = ",")[,1]#调用描述符
data_select<-result_1[,desc_value]#选择描述符数据
data_value_pred<- data.frame(SMILES = result_1$moldb_smiles,data_select)
sweetvaluepred.prediction <- rf_model %>% predict(data_value_pred)
data_value_all<-data.frame(SMILES=data_value_pred$SMILES,value = sweetvaluepred.prediction)
sweetvalue <- data_value_all
